#!/bin/sh

# Part of Zombie Navigator
# Copyright © 2015  Zombie Navigator Developers

dir="`dirname "$0"`"
dir="`cd "$dir";pwd`"
cd "$dir/src"

if [ -x "$1" ] && [ -f "$1" ] ; then
	JPM_FIREFOX_BINARY="$1"
elif [ -x "$JPM_FIREFOX_BINARY" ] && [ -f "$JPM_FIREFOX_BINARY" ] ; then
	JPM_FIREFOX_BINARY="$JPM_FIREFOX_BINARY"
elif which firefox >/dev/null 2>&1 ; then
	JPM_FIREFOX_BINARY="`which firefox`"
elif [ -x "$HOME/.local/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="$HOME/.local/bin/firefox"
	
elif [ -x "$HOME/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="$HOME/bin/firefox"
	
elif [ -x "/usr/local/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="/usr/local/bin/firefox"
	
elif [ -x "/usr/bin/firefox" ] ; then
	JPM_FIREFOX_BINARY="/usr/bin/firefox"
	
elif [ -x "/Applications/Firefox.app/Contents/MacOS/firefox" ] ; then
	# OS/X
	JPM_FIREFOX_BINARY="/Applications/Firefox.app/Contents/MacOS/firefox"
	
elif [ -x "$HOME/Applications/Firefox.app/Contents/MacOS/firefox" ] ; then
	# OS/X, per user
	
	JPM_FIREFOX_BINARY="$HOME/Applications/Firefox.app/Contents/MacOS/firefox"
	
fi

if [ "$JPM_FIREFOX_BINARY" ] ; then
	export JPM_FIREFOX_BINARY
fi


# Run Firefox
if ! which jpm >/dev/null 2>&1 ; then
	echo "Please install jpm somewhere in PATH" >&2
	exit 1
fi

jpm run


# vim: ts=4 noet ai

